<?php
if($_POST['mode'] == 1)
{
        if($_POST['auto_air'] == "0")
        {
                $cmd = "/home/pi/modules/ITemp.sh auto_air ".$_POST['auto_air'];
                system($cmd);
                echo "<div class=\"alert alert-info\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><i class=\"icon-remove\"></i></button>设置手动模式成功</div>";
        }
        else
        {
                $cmd = "/home/pi/modules/ITemp.sh auto_air ".$_POST['auto_air'];
                system($cmd);
                echo "<div class=\"alert alert-info\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><i class=\"icon-remove\"></i></button>设置自动模式成功</div>";
        }
}

if($_POST['mode'] == 2)
{
	if(17<=$_POST['TEMP'] && $_POST['TEMP']<=30 )
	{
	   $cmd = "/home/pi/modules/ITemp.sh TEMP ".$_POST['TEMP'];
	    system($cmd);
	}
	else
	{
		echo "<div class=\"alert alert-info\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"></button>输入错误！请重新输入。</div>";
	}
	 
	 $cmd = "/home/pi/modules/ITemp.sh AIR_TEMP ".$_POST['AIR_TEMP'];
	  system($cmd);
 }
?>

<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="assets/css/style.css"/>     
<link rel="stylesheet" href="assets/css/ace.min.css" >
<script src="assets/js/jquery-1.9.1.min.js"></script>     
<script src="assets/js/bootstrap.min.js"></script>		
<title>系统设置</title>

</head>

<body>
<div class="margin clearfix">
 <div class="stystems_style">
  <div class="tabbable">
	<ul class="nav nav-tabs" id="myTab">
	  <li class="active">
		<a data-toggle="tab" href="#home"><i class="green fa fa-home bigger-110"></i>&nbsp;基本设置</a></li>
      <li class="">
		<a data-toggle="tab" href="#profile">消息通知<span class="badge badge-danger">4</span></a></li>
	</ul>
    <div class="tab-content">
		<div id="home" class="tab-pane active">
         <div class="form-group"><div class="col-sm-2"></div>
		 <label class="col-sm-2 control-label no-padding-right" for="form-field-1"><i>*</i>模式选择：</label>
          <div class="col-sm-4" style="margin-left:11px;">
		<form action="system.php" method="post" enctype="multipart/form-data">
		<input type="hidden" name="mode" value="1">
		<?php
		require ("../ITemp.php");
		if($SENSOR['auto_air']== "1")
		{
		 echo "</br>";
                echo "<input type='hidden' name='auto_air' value='0'>";
                echo "<button type='submit' class=\"btn btn-default\">手动模式</button>";
				echo "<i>当前为自动模式</i>";
        }
        else
        {       
                echo "<input type='hidden' name='auto_air' value='1'>";
                echo "<button type='submit' class=\"btn btn-default\">自动模式</button>";
				echo "<i>当前为手动模式</i>";
        }
		echo "</br>"; 	
		?>
		</form>
		  </div>
          </div>
	  
           <div class="form-group"><div class="col-sm-2"></div><label class="col-sm-2 control-label no-padding-right" for="form-field-1"><i>*</i>当前室内温度： </label>
          <div class="col-sm-4"><input type="text" name="temperature" readonly value="<?php echo $SENSOR['env_temp'];?>℃"/></div>
          </div>
          <div class="form-group"><div class="col-sm-2"></div><label class="col-sm-2 control-label no-padding-right" for="form-field-1"><i>*</i>当前室内湿度： </label>
          <div class="col-sm-4"><input type="text" name="humidity"  readonly value="<?php echo $SENSOR['env_rh']; ?>℉"/></div>
          </div>
		  
		  <form role="form" action="system.php" method="post" >
		  <input type="hidden" name="mode" value="2">
		  	<div class="form-group"><div class="col-sm-2"></div><label class="col-sm-2 control-label no-padding-right" for="form-field-1"><i>*</i>设置温度警戒线：</label>
		   <div class="col-sm-2">
           <div class="input-group">
			<input type="text" class="form-control" name="TEMP" value="<?php echo $SENSOR['TEMP']; ?>">
			<span class="input-group-addon">℃</span>
		  </div>
		  </div>
			<i>（17℃-30℃）温度超过该值空调自动开启</i>	
          </div>

	      <div class="form-group"><div class="col-sm-2"></div>
		  <label class="col-sm-2 control-label no-padding-right" for="form-field-1"><i>*</i>设置空调开机温度： </label>
			<div class="col-sm-2" style="margin-left:11px;">
				  <div class="form-group" >
					<select class="form-control"name="AIR_TEMP">
						<option value="">请选择</option>
					  <option value="1">17℃</option>
					  <option value="2">18℃</option>
					  <option value="3">19℃</option>
					  <option value="4">20℃</option>
					  <option value="5">21℃</option>
					  <option value="6">22℃</option>
					  <option value="7">23℃</option>
					  <option value="8">24℃</option>
					  <option value="9">25℃</option>
					  <option value="10">26℃</option>
					  <option value="11">27℃</option>
					  <option value="12">28℃</option>
					  <option value="13">29℃</option>
					  <option value="14">30℃</option>
					 
					</select>		
				  </div>	  
			</div>	
			<i>当前空调开机温度为：<b><?php require ("../ITemp.php"); $val=$SENSOR['AIR_TEMP']+16;echo $val;?></b>℃</i>			
         </div>
		  
		   <div class="Button_operation"> 
		  <button  class="btn btn-primary" type="submit">提交</button>
		  </div>
          </form> 
        </div>
		</div>
		</div>
 </div>
</div>
</body>
</html>
